﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using MinhTam.DataAccess.Web;

public partial class albumanh : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitList();
        }
    }
    private void InitList()
    {
        string sql = string.Format(@"SELECT abc.ALBUM_ID, abc.tEN_ALBUM +' ('+ CONVERT(NVARCHAR(10), abc.DEM) +N' ảnh )'  TEN_ALBUM,abc.THUMBNAIL
                    FROM
                    (
                    SELECT aa.ALBUM_ID, aa.TEN_ALBUM,
                    (SELECT TOP 1 '{0}'+ ha.URL_IMAGE 
                    FROM HINH_ANH ha WHERE ha.Album_ID=aa.ALBUM_ID AND ha.IS_ANH_BIA='Y') THUMBNAIL,
                     (SELECT COUNT(*) FROM HINH_ANH ha WHERE ha.Album_ID=aa.ALBUM_ID) DEM                    
                    FROM ALBUM_ANH aa
                    where aa.ALBUM_ID NOT IN {1}
    
                    ) abc
                    WHERE abc.dem>0                    
                    ORDER BY abc.TEN_ALBUM", HelpConstEnum.UPLOAD_IMAGE_FOLDER, HelpConstEnum.FIX_ALBUM);
        DataTable dt = SQLConnectWeb.GetTable(sql);
        listImage.DataSource = dt;
        listImage.DataBind();
    }

}